﻿using System;
using System.Collections.Generic;

namespace YasharEl.Infrastructure.ServiceBus
{
    /// <summary>
    /// Used to specify the order in which message handlers will be activated.
    /// </summary>
    public class Order
    {
        #region Getters

        ///<summary>
        /// Gets the types whose order has been specified.
        ///</summary>
        public IEnumerable<Type> Types { get; private set; }

        #endregion

        #region Methods

        /// <summary>
        /// Specifies that the given type will be activated before all others.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public void SpecifyFirst<T>()
        {
            Types = new[] { typeof(T) };
        }

        /// <summary>
        /// Specifies an ordering of multiple types using the syntax:
        /// First{H1}.Then{H2}().AndThen{H3}()... etc
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ordering"></param>
        public void Specify<T>(First<T> ordering)
        {
            Types = ordering.Types;
        }

        #endregion
    }
}
